﻿
Public Class rate_timeout
    Private ReadOnly rate_ms As Double
    Private ms As Int64
    Private size As UInt32

    Public Sub New(ByVal rate_sec As UInt32)
        Me.rate_ms = rate_sec
        Me.rate_ms /= constants.second_milli
    End Sub

    Public Sub update(ByVal size As UInt32)
        Me.ms = nowadays.milliseconds()
        Me.size = size
    End Sub

    Public Function timeout() As Boolean
        Return rate_ms > 0 AndAlso
               nowadays.milliseconds() > ms AndAlso
               rate_ms * (nowadays.milliseconds() - ms) > size
    End Function
End Class
